package com.example.leetdemo.process;

public class Solution2965 {

    public int[] findMissingAndRepeatedValues(int[][] grid) {
        int max = grid.length * grid.length;
        int[] aa = new int[max + 1];
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[i].length; j++) {
                aa[grid[i][j]]++;
            }
        }
        int[] result = new int[2];
        for (int i = 1; i < aa.length; i++) {
            if (aa[i] == 2) {
                result[0] = i;
            }
            if (aa[i] == 0) {
                result[1] = i;
            }
        }
        return result;
    }
}
